package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysNlpStopWord;
import com.ruoyi.system.service.ISysNlpStopWordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 停用词Controller
 * 
 * @author ruoyi
 * @date 2022-08-27
 */
@RestController
@RequestMapping("/system/stopWord")
public class SysNlpStopWordController extends BaseController
{
    @Autowired
    private ISysNlpStopWordService sysNlpStopWordService;

    /**
     * 查询停用词列表
     */
    @PreAuthorize("@ss.hasPermi('system:stopWord:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysNlpStopWord sysNlpStopWord)
    {
        startPage();
        List<SysNlpStopWord> list = sysNlpStopWordService.selectSysNlpStopWordList(sysNlpStopWord);
        return getDataTable(list);
    }

    /**
     * 导出停用词列表
     */
    @PreAuthorize("@ss.hasPermi('system:stopWord:export')")
    @Log(title = "停用词", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysNlpStopWord sysNlpStopWord)
    {
        List<SysNlpStopWord> list = sysNlpStopWordService.selectSysNlpStopWordList(sysNlpStopWord);
        ExcelUtil<SysNlpStopWord> util = new ExcelUtil<SysNlpStopWord>(SysNlpStopWord.class);
        return util.exportExcel(list, "停用词数据");
    }

    /**
     * 获取停用词详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:stopWord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysNlpStopWordService.selectSysNlpStopWordById(id));
    }

    /**
     * 新增停用词
     */
    @PreAuthorize("@ss.hasPermi('system:stopWord:add')")
    @Log(title = "停用词", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysNlpStopWord sysNlpStopWord)
    {
        return toAjax(sysNlpStopWordService.insertSysNlpStopWord(sysNlpStopWord));
    }

    /**
     * 修改停用词
     */
    @PreAuthorize("@ss.hasPermi('system:stopWord:edit')")
    @Log(title = "停用词", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysNlpStopWord sysNlpStopWord)
    {
        return toAjax(sysNlpStopWordService.updateSysNlpStopWord(sysNlpStopWord));
    }

    /**
     * 删除停用词
     */
    @PreAuthorize("@ss.hasPermi('system:stopWord:remove')")
    @Log(title = "停用词", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysNlpStopWordService.deleteSysNlpStopWordByIds(ids));
    }
}
